#ifndef SEARCH_H
#define SEARCH_H

#include <QWidget>
#include "globalval.h"
#include <QLabel>
#include <QMap>
#include <QListWidgetItem>  // 添加这行

namespace Ui {
class Search;
}

class Search : public QWidget
{
    Q_OBJECT

public:
    explicit Search(QWidget *parent = 0);
    ~Search();

public slots:
    void dataUpSlot(const QByteArray& msg);
    void setConnectedState(bool connected);

protected:
    void resizeEvent(QResizeEvent *event) override;

private slots:
    void on_refreshButton_clicked();

private:
    Ui::Search *ui;
    bool isConnected;
    QLabel *overlayLabel;

    // 新增：设备列表管理
    QMap<QString, QListWidgetItem*> deviceItems;  // 存储设备ID和对应的列表项

    void createOverlay();
    void destroyOverlay();
    void updateDisconnectedState();
    void addOrUpdateDevice(const QString& deviceId, int devstate);  // 新增：添加或更新设备
};

#endif // SEARCH_H
